package com.osdp.uc.feign;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class UcFeignServiceFallbackFactory implements FallbackFactory<UcFeignService> {

    private final UcFeignServiceFallback ucFeignServiceFallback;

    public UcFeignServiceFallbackFactory(UcFeignServiceFallback ucFeignServiceFallback){
        this.ucFeignServiceFallback = ucFeignServiceFallback;
    }

    @Override
    public UcFeignService create(Throwable throwable) {
        //打印下异常
        if(log.isErrorEnabled()){
            log.error("发生异常:{}",throwable);
        }
        return ucFeignServiceFallback;
    }
}
